﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace _页面加载与加载完成.Handler
{
    /// <summary>
    /// EasyuiHander 的摘要说明
    /// </summary>
    public class EasyuiHander : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //StringBuilder sb = new StringBuilder();
            //sb.Append("<div title=\"菜单测试一\" style=\"overflow:auto;\">");
            //sb.Append("<div style=\"text-align:center\"><a href=\"javascript:void(0)\">测试一</a></div>");
            //sb.Append("<div style=\"text-align:center\"><a href=\"javascript:void(0)\">测试二</a></div>");
            //sb.Append("<div style=\"text-align:center\"><a href=\"javascript:void(0)\">测试三</a></div>");
            //sb.Append("</div> ");
            //sb.Append("<div title=\"菜单测试二\" style=\"overflow:auto;\">");
            //sb.Append("<div style=\"text-align:center\"><a href=\"javascript:void(0)\">测试一</a></div>");
            //sb.Append("<div style=\"text-align:center\"><a href=\"javascript:void(0)\">测试二</a></div>");
            //sb.Append("</div>");

            List<Person> people = new List<Person> {
                new Person(){ Id=1, Name="张三", Birthday=DateTime.Now.AddYears(-22) },
                new Person(){ Id=2, Name="小明", Birthday=DateTime.Now.AddYears(-21) },
                new Person(){ Id=3, Name="小红", Birthday=DateTime.Now.AddYears(-25) }
            };


            context.Response.Write(JsonConvert.SerializeObject(people));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
    public class Person
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public DateTime Birthday { get; set; }
    }
}